#include "dxstdafx.h"
#include "ResManager.h"
#include <string>
using namespace std;

ResManager::ResManager(void)
{
}

ResManager::~ResManager(void)
{
}

LRESULT ResManager::Initial(IDirect3DDevice9* pDevice)
{
	// Use D3DX to create a texture from a file based image
	wchar_t strColor[6][222] = {L"Red.jpg", L"Orange.jpg", L"Yellow.jpg", L"White.jpg", L"Blue.jpg", L"Green.jpg"};
	for (int i = 0; i < 6; ++i)
	{
		wchar_t strFile[MAX_PATH];
		wcscpy_s(strFile, MAX_PATH, L"res\\");
		wcscat_s(strFile, MAX_PATH, strColor[i]);
		m_textureCube[i] = NULL;
		if( FAILED( D3DXCreateTextureFromFile( pDevice, strFile, &m_textureCube[i] ) ) )
		{
			MessageBox( NULL, L"Could not find texture file", strFile, MB_OK );
			return E_FAIL;
		}
	}
	return S_OK;
}

LRESULT ResManager::Destroy()
{
	for (int i = 0; i < 6; ++i)
	{
		SAFE_RELEASE(m_textureCube[i]);
	}
	return S_OK;
}

LPDIRECT3DTEXTURE9 ResManager::GetCubeTexture(int index)
{
	if (index>=0 && index < 6)
	{
		return m_textureCube[index];
	}
	return NULL;
}
